<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ include file="common/include/header.jsp" %>

<div>
<table border="0" cellpadding="0" cellspacing="0" width="980px">
	<tr>
		<td style="vertical-align: top;width: 180px;background-image: url('<%=imagePath %>main_leftbg.jpg');">
		</td>
		
		<td style="text-align: center;width: 800px; vertical-align: top;">
	
<table style="width: 800px;height: 500px;text-align: center;padding-top: 5px;" cellpadding="0"  cellspacing="0">
					
<!-- 공지사항 최신게시물 -->
		<tr><td id="noticeTD" style="width: 300px;vertical-align: top;height: 120px;">
	<table style="width: 290px;">
				<tr><td colspan="2" style="height: 20px;width: 260px;">
					<img src="<%=imagePath %>main_noticeicon_01.jpg" border="0"/>
					</td>
					<td style="width: 30px;"><a href="javascript:getNotice();">
					<img src="<%=imagePath %>icon_more.jpg" border="0"/></a></td>
					</tr>
	</table>
	<table style="width: 290px;background: #ffffff;border: 1px dotted #dddddd;">
		<tbody id="noticeTbody">
		</tbody>
	</table>

		</td>

<!-- 자유게시판 최신게시물 -->	
		<td id="freeTD" style="width: 300px;vertical-align: top;height: 120px;">
	<table style="width: 290px;">
				<tr><td colspan="2" style="height: 20px;width: 260px;">
				<img src="<%=imagePath %>main_freeicon_01.jpg" border="0"/>
				</td>
					<td style="width: 30px;"><a href="javascript:getBoard('freeboard.do?method=getList&cono=5&fbname=','자유게시판');">
					<img src="<%=imagePath %>icon_more.jpg" border="0"/></a></td></tr>
	</table>		
	<table style="width: 290px;background: #ffffff;border: 1px dotted #dddddd;">
		<tbody id="freeTbody">
		</tbody>
	</table>
		</td>
		<td rowspan="3" style="width: 200px; background-image: url('<%=imagePath %>welcome02.jpg');"/></td>
		</tr>
		
<!-- 포토앨범 최신 게시물 -->		
	<tr><td colspan="2" style="text-align: center;width: 600px;vertical-align: top; height: 170px;">
<table style="width: 590px;">
		<tr><td colspan="2" style="height: 20px;width: 560px;text-align: left;">
		<img src="<%=imagePath %>main_photoicon_01.jpg" border="0"/>
		</td>
			<td style="width: 30px;"><a href="javascript:getBoard('photoboard.do?method=photoList&cono=4&pbname=','포토갤러리');">
			<img src="<%=imagePath %>icon_more.jpg" border="0"/></a></td></tr>
</table>
<table style="width: 590px; background: #ffffff;border:1px dotted #dddddd;height: 150px;">
	<tbody id="photoTbody">
	</tbody>
</table>
		</td></tr>
		
<!-- 자료실 링크 -->
	<tr><td colspan="2" style="text-align: center;width: 600px;vertical-align: top;height: 140px;">
<table style="width: 590px;">
		<tr><td colspan="2" style="height: 20px;width: 560px;text-align: left;">
		<img src="<%=imagePath %>main_dataicon_05.jpg" border="0"/>
		</td>
			<td style="width: 30px;"><a href="javascript:;">
			<img src="<%=imagePath %>icon_more.jpg" border="0"/></a></td></tr>
</table>
<table style="width: 590px;border 1px dotted #dddddd;height:120px;">
	<tr><td><a href="javascript:getBoard('databoard.do?method=getList&cono=7&dbname=','일본어자료실');">
			<img src="<%=imagePath %>main_dataicon_01.jpg" style="border: 1px solid #dddddd;"/></a></td>
		<td><a href="javascript:getBoard('databoard.do?method=getList&cono=7&dbname=','일본어강좌');">
			<img src="<%=imagePath %>main_dataicon_02.jpg" style="border: 1px solid #dddddd;"/></a></td></tr>
	<tr><td><a href="javascript:getBoard('databoard.do?method=getList&cono=7&dbname=','프로그램자료실');">
			<img src="<%=imagePath %>main_dataicon_03.jpg" style="border: 1px solid #dddddd;"/></a></td>
		<td><a href="javascript:getBoard('databoard.do?method=getList&cono=7&dbname=','프로그램강좌');">
			<img src="<%=imagePath %>main_dataicon_04.jpg" style="border: 1px solid #dddddd;"/></a></td></tr>		
</table>
		</td></tr>
		
</table>
			
		</td>
	</tr>
</table>
</div>

<script type="text/javascript">
<!--
	window.attachEvent("onload",callBoards);
	
	var xmlHttp;
	
	function callBoards(){
		var url = "<%=path%>/board/menuajaxaction.do?method=welcome";
		createXMLHttpRequest();
	    xmlHttp.onreadystatechange = handleStateChange;
	    xmlHttp.open("GET", url, true);
	    xmlHttp.send(null);
		
	}
		function createXMLHttpRequest() {
	    if (window.ActiveXObject) {
	        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } 
	    else if (window.XMLHttpRequest) {
	        xmlHttp = new XMLHttpRequest();
	    }
	}
	
	function handleStateChange() {
	    if(xmlHttp.readyState == 4) {
	    	if(xmlHttp.status == 200){
	    		parseResponse();	       
			}	           
	    }
	}
	
	function parseResponse(){

		var xmlDoc = xmlHttp.responseXML;
		
		var notices = xmlDoc.getElementsByTagName('notice');
		var nTbody = noticeTbody;
		for(var i=0;i<notices.length;i++){
			var no = notices[i].getElementsByTagName('nbno')[0].firstChild.nodeValue;
			var title = notices[i].getElementsByTagName('nbtitle')[0].firstChild.nodeValue;
			var date = notices[i].getElementsByTagName('nbdate')[0].firstChild.nodeValue;
			var cono = notices[i].getElementsByTagName('cono')[0].firstChild.nodeValue;
			var url = "noticeboard.do?method=detailView&cono="+cono+"&nbno=";
			nTbody.appendChild(createCell(no,title,date,url));		
		}

		var frees = xmlDoc.getElementsByTagName('free');
		var fTbody = freeTbody;
		for(var i=0;i<frees.length;i++){
			var no = frees[i].getElementsByTagName('fbno')[0].firstChild.nodeValue;
			var cono = frees[i].getElementsByTagName('cono')[0].firstChild.nodeValue;
			var title = frees[i].getElementsByTagName('fbtitle')[0].firstChild.nodeValue;
			var date = frees[i].getElementsByTagName('fbdate')[0].firstChild.nodeValue;
			var fbname = frees[i].getElementsByTagName('fbname')[0].firstChild.nodeValue;
			var url = "freeboard.do?method=detailView&cono="+cono+"&fbno="+no+"&fbname="+escape(encodeURIComponent(fbname));
			fTbody.appendChild(createCell(no,title,date,url));
		}
		
		var photos = xmlDoc.getElementsByTagName('photo');
		var pTbody = photoTbody;
		var pTr = document.createElement('tr');
		for(var i=0;i<photos.length;i++){
			var no = photos[i].getElementsByTagName('pbno')[0].firstChild.nodeValue;
			var cono = photos[i].getElementsByTagName('cono')[0].firstChild.nodeValue;
			var title = photos[i].getElementsByTagName('pbtitle')[0].firstChild.nodeValue;
			var sfn = photos[i].getElementsByTagName('pbsfn')[0].firstChild.nodeValue;
			var pbname = photos[i].getElementsByTagName('pbname')[0].firstChild.nodeValue;
			var url = "photoboard.do?method=photoView&cono="+cono+"&pbno="+no+"&pbname="+escape(encodeURIComponent(pbname));
			pTr.appendChild(createPhotoCell(no,title,sfn,url));
			
		}              
		pTbody.appendChild(pTr);
		
		xmlHttp = null;
	}
	
	function createCell(no,title,date,url){
		var cell = document.createElement('tr');
		
		var _iconImage = document.createElement('td');
		_img = document.createElement('img');
		_img.src = "<%=imagePath %>icon_topmenu.jpg";
		_iconImage.appendChild(_img);
		
		var _title = document.createElement('td');
		
		var _link = document.createElement('a');
		_link.appendChild(document.createTextNode(title));
		_link.href = "<%=path%>/board/"+url+no;
		_title.appendChild(_link);
		_title.style.textAlign = "left";
		_title.style.width = "250";
		
		var _date = document.createElement('td');
		_date.appendChild(document.createTextNode("["+date.replace(/\-/g,"\/")+"]"));
		_date.style.fontSize = "8pt";
		
		cell.appendChild(_iconImage);
		cell.appendChild(_date);
		cell.appendChild(_title);
		
		return cell;
	}
	
	function createPhotoCell(no,title,sfn,url){
		var cell = document.createElement('td');
		
		var _Image = document.createElement('img');
		_Image.src = "<%=uploadPath %>"+sfn;
		_Image.style.width = "130";
		_Image.style.height = "130";
		_Image.alt = title;
		_Image.style.borderWidth = "0";
		_Image.name = no;
		
		var _link = document.createElement('a');
		_link.appendChild(_Image);
		_link.href = "<%=path%>/board/"+url;
		_link.onfocus = blur;
		
		cell.appendChild(_link);
		cell.style.height = "140";
		cell.style.width = "140";
		
		return cell;
	}
	
	
//

	function getBoard(u,b){
		var url = '<%=path%>/board/'+u;
		url = url + escape(encodeURIComponent(b));
		location.href=url;
	}
	
	function getNotice(){
		location.href="<%=path %>/board/noticeboard.do?method=getList&cono=6";
	}
//-->
</script>
<%@ include file="common/include/footer.jsp" %>
